{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "第一周作业,姓名：曾露莎"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入包\n",
    "\n",
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "\n",
    "#from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "from sklearn.metrics import mean_squared_error  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "# 图形出现在Notebook里而不是新窗口\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>season_1</th>\n",
       "      <th>season_2</th>\n",
       "      <th>season_3</th>\n",
       "      <th>season_4</th>\n",
       "      <th>mnth_1</th>\n",
       "      <th>mnth_2</th>\n",
       "      <th>mnth_3</th>\n",
       "      <th>mnth_4</th>\n",
       "      <th>mnth_5</th>\n",
       "      <th>...</th>\n",
       "      <th>weekday_5</th>\n",
       "      <th>weekday_6</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>holiday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>yr</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.355170</td>\n",
       "      <td>0.373517</td>\n",
       "      <td>0.828620</td>\n",
       "      <td>0.284606</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.379232</td>\n",
       "      <td>0.360541</td>\n",
       "      <td>0.715771</td>\n",
       "      <td>0.466215</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.171000</td>\n",
       "      <td>0.144830</td>\n",
       "      <td>0.449638</td>\n",
       "      <td>0.465740</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.175530</td>\n",
       "      <td>0.174649</td>\n",
       "      <td>0.607131</td>\n",
       "      <td>0.284297</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.209120</td>\n",
       "      <td>0.197158</td>\n",
       "      <td>0.449313</td>\n",
       "      <td>0.339143</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant  season_1  season_2  season_3  season_4  mnth_1  mnth_2  mnth_3  \\\n",
       "0        1         1         0         0         0       1       0       0   \n",
       "1        2         1         0         0         0       1       0       0   \n",
       "2        3         1         0         0         0       1       0       0   \n",
       "3        4         1         0         0         0       1       0       0   \n",
       "4        5         1         0         0         0       1       0       0   \n",
       "\n",
       "   mnth_4  mnth_5  ...   weekday_5  weekday_6      temp     atemp       hum  \\\n",
       "0       0       0  ...           0          1  0.355170  0.373517  0.828620   \n",
       "1       0       0  ...           0          0  0.379232  0.360541  0.715771   \n",
       "2       0       0  ...           0          0  0.171000  0.144830  0.449638   \n",
       "3       0       0  ...           0          0  0.175530  0.174649  0.607131   \n",
       "4       0       0  ...           0          0  0.209120  0.197158  0.449313   \n",
       "\n",
       "   windspeed  holiday  workingday  yr   cnt  \n",
       "0   0.284606        0           0   0   985  \n",
       "1   0.466215        0           0   0   801  \n",
       "2   0.465740        0           1   0  1349  \n",
       "3   0.284297        0           1   0  1562  \n",
       "4   0.339143        0           1   0  1600  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#导入数据\n",
    "data = pd.read_csv(\"FE_day.csv\")\n",
    "\n",
    "#通过观察前5行，了解数据每列（特征）的概况\n",
    "data.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(731, 35)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#数据行列\n",
    "data.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>season_1</th>\n",
       "      <th>season_2</th>\n",
       "      <th>season_3</th>\n",
       "      <th>season_4</th>\n",
       "      <th>mnth_1</th>\n",
       "      <th>mnth_2</th>\n",
       "      <th>mnth_3</th>\n",
       "      <th>mnth_4</th>\n",
       "      <th>mnth_5</th>\n",
       "      <th>...</th>\n",
       "      <th>weekday_5</th>\n",
       "      <th>weekday_6</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>holiday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>yr</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>366.000000</td>\n",
       "      <td>0.247606</td>\n",
       "      <td>0.251710</td>\n",
       "      <td>0.257182</td>\n",
       "      <td>0.243502</td>\n",
       "      <td>0.084815</td>\n",
       "      <td>0.077975</td>\n",
       "      <td>0.084815</td>\n",
       "      <td>0.082079</td>\n",
       "      <td>0.084815</td>\n",
       "      <td>...</td>\n",
       "      <td>0.142271</td>\n",
       "      <td>0.143639</td>\n",
       "      <td>0.543594</td>\n",
       "      <td>0.518864</td>\n",
       "      <td>0.645649</td>\n",
       "      <td>0.346536</td>\n",
       "      <td>0.028728</td>\n",
       "      <td>0.683995</td>\n",
       "      <td>0.500684</td>\n",
       "      <td>4504.348837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>211.165812</td>\n",
       "      <td>0.431917</td>\n",
       "      <td>0.434293</td>\n",
       "      <td>0.437380</td>\n",
       "      <td>0.429489</td>\n",
       "      <td>0.278797</td>\n",
       "      <td>0.268316</td>\n",
       "      <td>0.278797</td>\n",
       "      <td>0.274674</td>\n",
       "      <td>0.278797</td>\n",
       "      <td>...</td>\n",
       "      <td>0.349567</td>\n",
       "      <td>0.350963</td>\n",
       "      <td>0.228091</td>\n",
       "      <td>0.213909</td>\n",
       "      <td>0.146457</td>\n",
       "      <td>0.159766</td>\n",
       "      <td>0.167155</td>\n",
       "      <td>0.465233</td>\n",
       "      <td>0.500342</td>\n",
       "      <td>1937.211452</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>183.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.346343</td>\n",
       "      <td>0.339674</td>\n",
       "      <td>0.534704</td>\n",
       "      <td>0.232045</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3152.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>366.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.547268</td>\n",
       "      <td>0.535113</td>\n",
       "      <td>0.644388</td>\n",
       "      <td>0.326928</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>4548.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>548.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.743002</td>\n",
       "      <td>0.695083</td>\n",
       "      <td>0.750857</td>\n",
       "      <td>0.434622</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>5956.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>731.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>8714.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          instant    season_1    season_2    season_3    season_4      mnth_1  \\\n",
       "count  731.000000  731.000000  731.000000  731.000000  731.000000  731.000000   \n",
       "mean   366.000000    0.247606    0.251710    0.257182    0.243502    0.084815   \n",
       "std    211.165812    0.431917    0.434293    0.437380    0.429489    0.278797   \n",
       "min      1.000000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "25%    183.500000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "50%    366.000000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "75%    548.500000    0.000000    1.000000    1.000000    0.000000    0.000000   \n",
       "max    731.000000    1.000000    1.000000    1.000000    1.000000    1.000000   \n",
       "\n",
       "           mnth_2      mnth_3      mnth_4      mnth_5     ...       \\\n",
       "count  731.000000  731.000000  731.000000  731.000000     ...        \n",
       "mean     0.077975    0.084815    0.082079    0.084815     ...        \n",
       "std      0.268316    0.278797    0.274674    0.278797     ...        \n",
       "min      0.000000    0.000000    0.000000    0.000000     ...        \n",
       "25%      0.000000    0.000000    0.000000    0.000000     ...        \n",
       "50%      0.000000    0.000000    0.000000    0.000000     ...        \n",
       "75%      0.000000    0.000000    0.000000    0.000000     ...        \n",
       "max      1.000000    1.000000    1.000000    1.000000     ...        \n",
       "\n",
       "        weekday_5   weekday_6        temp       atemp         hum   windspeed  \\\n",
       "count  731.000000  731.000000  731.000000  731.000000  731.000000  731.000000   \n",
       "mean     0.142271    0.143639    0.543594    0.518864    0.645649    0.346536   \n",
       "std      0.349567    0.350963    0.228091    0.213909    0.146457    0.159766   \n",
       "min      0.000000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "25%      0.000000    0.000000    0.346343    0.339674    0.534704    0.232045   \n",
       "50%      0.000000    0.000000    0.547268    0.535113    0.644388    0.326928   \n",
       "75%      0.000000    0.000000    0.743002    0.695083    0.750857    0.434622   \n",
       "max      1.000000    1.000000    1.000000    1.000000    1.000000    1.000000   \n",
       "\n",
       "          holiday  workingday          yr          cnt  \n",
       "count  731.000000  731.000000  731.000000   731.000000  \n",
       "mean     0.028728    0.683995    0.500684  4504.348837  \n",
       "std      0.167155    0.465233    0.500342  1937.211452  \n",
       "min      0.000000    0.000000    0.000000    22.000000  \n",
       "25%      0.000000    0.000000    0.000000  3152.000000  \n",
       "50%      0.000000    1.000000    1.000000  4548.000000  \n",
       "75%      0.000000    1.000000    1.000000  5956.000000  \n",
       "max      1.000000    1.000000    1.000000  8714.000000  \n",
       "\n",
       "[8 rows x 35 columns]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#数据信息\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 731 entries, 0 to 730\n",
      "Data columns (total 35 columns):\n",
      "instant         731 non-null int64\n",
      "season_1        731 non-null int64\n",
      "season_2        731 non-null int64\n",
      "season_3        731 non-null int64\n",
      "season_4        731 non-null int64\n",
      "mnth_1          731 non-null int64\n",
      "mnth_2          731 non-null int64\n",
      "mnth_3          731 non-null int64\n",
      "mnth_4          731 non-null int64\n",
      "mnth_5          731 non-null int64\n",
      "mnth_6          731 non-null int64\n",
      "mnth_7          731 non-null int64\n",
      "mnth_8          731 non-null int64\n",
      "mnth_9          731 non-null int64\n",
      "mnth_10         731 non-null int64\n",
      "mnth_11         731 non-null int64\n",
      "mnth_12         731 non-null int64\n",
      "weathersit_1    731 non-null int64\n",
      "weathersit_2    731 non-null int64\n",
      "weathersit_3    731 non-null int64\n",
      "weekday_0       731 non-null int64\n",
      "weekday_1       731 non-null int64\n",
      "weekday_2       731 non-null int64\n",
      "weekday_3       731 non-null int64\n",
      "weekday_4       731 non-null int64\n",
      "weekday_5       731 non-null int64\n",
      "weekday_6       731 non-null int64\n",
      "temp            731 non-null float64\n",
      "atemp           731 non-null float64\n",
      "hum             731 non-null float64\n",
      "windspeed       731 non-null float64\n",
      "holiday         731 non-null int64\n",
      "workingday      731 non-null int64\n",
      "yr              731 non-null int64\n",
      "cnt             731 non-null int64\n",
      "dtypes: float64(4), int64(31)\n",
      "memory usage: 200.0 KB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "y = data['cnt'].values\n",
    "X = data.drop(['cnt','instant'], axis = 1)\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lusha/.local/lib/python3.6/site-packages/sklearn/utils/validation.py:590: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "#该数据已经做过X的数值型归一化处理和类型编码，但是对y未做归一化，虽然对y归一化不是必须的，但是还是归一\n",
    "\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "mn_y = MinMaxScaler()\n",
    "y = mn_y.fit_transform(y.reshape(-1,1))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(584, 33)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将数据分割训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.2)\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>season_4</td>\n",
       "      <td>[8148280928973.255]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>season_2</td>\n",
       "      <td>[8148280928973.168]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>season_3</td>\n",
       "      <td>[8148280928973.135]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>season_1</td>\n",
       "      <td>[8148280928973.084]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.28970648628740114]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>yr</td>\n",
       "      <td>[0.2316968278188186]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.12656335218459983]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.14211859647222003]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.15917471278162595]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>weekday_5</td>\n",
       "      <td>[-246020738397.98853]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>weekday_4</td>\n",
       "      <td>[-246020738397.9921]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>weekday_3</td>\n",
       "      <td>[-246020738397.99387]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>weekday_2</td>\n",
       "      <td>[-246020738398.00458]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>weekday_1</td>\n",
       "      <td>[-246020738398.0233]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>mnth_9</td>\n",
       "      <td>[-1381047771675.5918]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>mnth_6</td>\n",
       "      <td>[-1381047771675.6436]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>mnth_5</td>\n",
       "      <td>[-1381047771675.6443]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>mnth_8</td>\n",
       "      <td>[-1381047771675.653]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>mnth_10</td>\n",
       "      <td>[-1381047771675.6594]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>mnth_3</td>\n",
       "      <td>[-1381047771675.672]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>mnth_4</td>\n",
       "      <td>[-1381047771675.681]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>mnth_7</td>\n",
       "      <td>[-1381047771675.7122]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>mnth_2</td>\n",
       "      <td>[-1381047771675.7324]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>mnth_1</td>\n",
       "      <td>[-1381047771675.7356]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>mnth_11</td>\n",
       "      <td>[-1381047771675.741]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>mnth_12</td>\n",
       "      <td>[-1381047771675.7551]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>weathersit_1</td>\n",
       "      <td>[-1389533972631.3665]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>weathersit_2</td>\n",
       "      <td>[-1389533972631.4177]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>weathersit_3</td>\n",
       "      <td>[-1389533972631.6228]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[-7953866503007.055]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-7953866503007.114]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>weekday_6</td>\n",
       "      <td>[-8199887241405.055]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>weekday_0</td>\n",
       "      <td>[-8199887241405.101]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columns                    coef\n",
       "3       season_4     [8148280928973.255]\n",
       "1       season_2     [8148280928973.168]\n",
       "2       season_3     [8148280928973.135]\n",
       "0       season_1     [8148280928973.084]\n",
       "26          temp   [0.28970648628740114]\n",
       "32            yr    [0.2316968278188186]\n",
       "27         atemp   [0.12656335218459983]\n",
       "29     windspeed  [-0.14211859647222003]\n",
       "28           hum  [-0.15917471278162595]\n",
       "24     weekday_5   [-246020738397.98853]\n",
       "23     weekday_4    [-246020738397.9921]\n",
       "22     weekday_3   [-246020738397.99387]\n",
       "21     weekday_2   [-246020738398.00458]\n",
       "20     weekday_1    [-246020738398.0233]\n",
       "12        mnth_9   [-1381047771675.5918]\n",
       "9         mnth_6   [-1381047771675.6436]\n",
       "8         mnth_5   [-1381047771675.6443]\n",
       "11        mnth_8    [-1381047771675.653]\n",
       "13       mnth_10   [-1381047771675.6594]\n",
       "6         mnth_3    [-1381047771675.672]\n",
       "7         mnth_4    [-1381047771675.681]\n",
       "10        mnth_7   [-1381047771675.7122]\n",
       "5         mnth_2   [-1381047771675.7324]\n",
       "4         mnth_1   [-1381047771675.7356]\n",
       "14       mnth_11    [-1381047771675.741]\n",
       "15       mnth_12   [-1381047771675.7551]\n",
       "16  weathersit_1   [-1389533972631.3665]\n",
       "17  weathersit_2   [-1389533972631.4177]\n",
       "18  weathersit_3   [-1389533972631.6228]\n",
       "31    workingday    [-7953866503007.055]\n",
       "30       holiday    [-7953866503007.114]\n",
       "25     weekday_6    [-8199887241405.055]\n",
       "19     weekday_0    [-8199887241405.101]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The RMSE of LinearRegression on test is 0.09472056824863244\n",
      "The RMSE of LinearRegression on train is 0.08590283939417438\n"
     ]
    }
   ],
   "source": [
    "# 使用RMSE评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print ('The RMSE of LinearRegression on test is', np.sqrt(mean_squared_error(y_test, y_test_pred_lr)))\n",
    "#训练集\n",
    "print ('The RMSE of LinearRegression on train is', np.sqrt(mean_squared_error(y_train, y_train_pred_lr)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAHqtJREFUeJzt3X2YnXV95/H3l2QgmgghIYmBgIkC8hSS0AHJWjA2IrRBkr3WBS1IWCJY0K5Va8GnMrXa1UK1ulAvs1gNghrIlpLVtQtNYVGq0CSmCARNRLImhmSI8hC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UV9+poGSmWzbto2NGzcybdq0Hu/H4W5JKsALL7zA+PHjDeghIiIYP358r0dGugzpiHh9RKxp9/NMRPxJRIyLiLsiYl31eGivKpGkYc6AHloa8X52GdKZ+ZPMnJmZM4HfAZ4HbgeuBlZk5jHAimpekiQ1SHfPSc8FfpaZGyJiPjCnWr4EuAe4qnGlSdLw1dLS//sbMWIE06dPZ8eOHUybNo2vf/3rjB07ttvHeve7380HP/hBTjjhhD2Wf+1rX2PlypVcf/313d4nwJgxY9i+fXtd286ZM4frrruO5ubm3ctWrlzJTTfdxBe/+MUeHX8gdPec9DuAb1bTkzJzczX9BDCpoydExOURsTIiVra2tvawTElSX3vFK17BmjVreOihhxg3bhw33HBDj/Zz44037hPQJWhubu7zgN65c2dD91d3SEfEgcB5wG17r6u+fq/Dr9PKzMWZ2ZyZzRMm1HWrUknSAJs9ezabNm3aPX/ttddy6qmncvLJJ3PNNdcA8NxzzzFv3jxmzJjBSSedxNKlS4FaL7btFtBf/epXOfbYYznttNO47777du/vkksuYdmyZbvnx4wZA8D27duZO3cup5xyCtOnT+eOO+7Yp7bNmzdz5plnMnPmTE466SS+973v1dWme+65h3PPPReAlpYWLr30UubMmcNrX/vaPcL75ptv5rTTTmPmzJm85z3v2R28V1xxBc3NzZx44om7XwOo3fL6qquu4pRTTuG22/aJyF7pznD37wOrM3NLNb8lIiZn5uaImAxsbWhlkqQBsXPnTlasWMGiRYsAuPPOO1m3bh0PPPAAmcl5553HvffeS2trK4cffjjf+c53AHj66af32M/mzZu55pprWLVqFYcccghvfvObmTVr1n6PPWrUKG6//XYOPvhgnnzySU4//XTOO++8PS7C+sY3vsHZZ5/Nxz72MXbu3Mnzzz/fo3Y++uij3H333Tz77LO8/vWv54orrmD9+vUsXbqU++67j6amJq688kpuueUWLr74Yj796U8zbtw4du7cydy5c3nwwQc5+eSTARg/fjyrV6/uUR37052Qfie/HeoGWA4sBD5TPe77cUeSNGj85je/YebMmWzatInjjz+es846C6iF9J133rk7YLdv3866des444w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Mzc3P1C3xrB5vNBs6IiCuBMcCBEbE9M4v4busGtK/9vn4ZEQ8BZ1AbXixCI9oYEQcD3wE+lpk/7KNSe6yR7+MgUc8tf9u22RgRI4FDgG39U15DDPXbGtfVvoh4C7UPm29qd2ptsOjue/gt4Et9WlEfKHm4ezm//cSzELhj7w0y88LMPCozp1Ib8r6plICuQ5fti4gpEfGKavpQ4Hfp2beIDZR62nggcDu1966YDx/d0GUbB6F6bvnbvt1vB/4lB9edkYb6bY27bF9EzAK+DJyXmYPxw2U9bTym3ew8YF0/1tcYmVnkD7XzWyuovaj/DIyrljcDN3aw/SXA9QNddyPbB5wFPAj8e/V4+UDX3QdtvAh4GVjT7mfmQNfeyDZW898DWoHfUDt3dvZA195Fu/4A+Cm16wM+Vi37JLVf6ACjgNuA9cADwGsHuuY+aOOp1Xv1HLVRgocHuuYGt++fgS3t/t8tH+ia+6CNXwAertp3N3DiQNfc3R9vCypJUqFKHu6WJGlYM6QlSSqUIS1JUqEMaUmSCmVIS5JUKENakqRCGdKSJBXq/wPbHpzw9gYKMwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The RMSE of RidgeCV on test is 0.09335218835687427\n",
      "The RMSE of RidgeCV on train is 0.08585974479088045\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用RMSE评价模型在测试集和训练集上的性能\n",
    "print ('The RMSE of RidgeCV on test is', np.sqrt(mean_squared_error(y_test, y_test_pred_ridge)))\n",
    "print ('The RMSE of RidgeCV on train is', np.sqrt(mean_squared_error(y_train, y_train_pred_ridge)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3Xl0XOWZ5/Hvo9WbbGNblrwigxcwOwhjErJ0SIihE0wIEDvgJj1MM326mel0n0yankzIDN19ZuiNORlIMnSgm7YdlkBInMQJWUwW0ki2DBgw2CCMS/Iub7JkWfszf9SVKRelUhnVrfX3OaeOrt773ltPlWX9dJd6X3N3RERE3q+SbBcgIiL5TUEiIiKjoiAREZFRUZCIiMioKEhERGRUFCQiIjIqChIRERkVBYmIiIyKgkREREalLNsFZMK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AEjP770RPTX1uhLq+ATxtZn8A/DTYfsjvBTWIhEqj/4qMkplN8OiseFOJHqV8MAiZsUSHXv9gcG0llX11uvuENNX1G2C5ux9Jx/5EhqMjEpHR+5GZTQYqgL92930A7n7CzL5GdG7slkwWFJx++yeFiGSCjkhERGRUdLFdRERGRUEiIiKjoiAREZFRUZCIiMioKEhERGRUFCQiIjIq/x8RjbGOdMjI/gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 1.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>season_4</td>\n",
       "      <td>[8148280928973.255]</td>\n",
       "      <td>[0.09038628358992584]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>season_2</td>\n",
       "      <td>[8148280928973.168]</td>\n",
       "      <td>[0.01146000591769003]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>season_3</td>\n",
       "      <td>[8148280928973.135]</td>\n",
       "      <td>[-0.009498696186014288]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>season_1</td>\n",
       "      <td>[8148280928973.084]</td>\n",
       "      <td>[-0.09234759332160153]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.28970648628740114]</td>\n",
       "      <td>[0.2060652077451491]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>yr</td>\n",
       "      <td>[0.2316968278188186]</td>\n",
       "      <td>[0.23238474693113942]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.12656335218459983]</td>\n",
       "      <td>[0.17792966011922565]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.14211859647222003]</td>\n",
       "      <td>[-0.12452623640158374]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.15917471278162595]</td>\n",
       "      <td>[-0.13008033628741705]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>weekday_5</td>\n",
       "      <td>[-246020738397.98853]</td>\n",
       "      <td>[0.009517613227277733]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>weekday_4</td>\n",
       "      <td>[-246020738397.9921]</td>\n",
       "      <td>[0.006972532701878531]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>weekday_3</td>\n",
       "      <td>[-246020738397.99387]</td>\n",
       "      <td>[0.0070049359952231716]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>weekday_2</td>\n",
       "      <td>[-246020738398.00458]</td>\n",
       "      <td>[-0.0038277183185988772]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>weekday_1</td>\n",
       "      <td>[-246020738398.0233]</td>\n",
       "      <td>[-0.02362642562435535]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>mnth_9</td>\n",
       "      <td>[-1381047771675.5918]</td>\n",
       "      <td>[0.08854943170182605]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>mnth_6</td>\n",
       "      <td>[-1381047771675.6436]</td>\n",
       "      <td>[0.040284304674968296]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>mnth_5</td>\n",
       "      <td>[-1381047771675.6443]</td>\n",
       "      <td>[0.038375549766223704]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>mnth_8</td>\n",
       "      <td>[-1381047771675.653]</td>\n",
       "      <td>[0.02955176157429122]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>mnth_10</td>\n",
       "      <td>[-1381047771675.6594]</td>\n",
       "      <td>[0.024689587768833565]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>mnth_3</td>\n",
       "      <td>[-1381047771675.672]</td>\n",
       "      <td>[0.0190571652561774]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>mnth_4</td>\n",
       "      <td>[-1381047771675.681]</td>\n",
       "      <td>[0.0013647004073436136]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>mnth_7</td>\n",
       "      <td>[-1381047771675.7122]</td>\n",
       "      <td>[-0.026912893663019744]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>mnth_2</td>\n",
       "      <td>[-1381047771675.7324]</td>\n",
       "      <td>[-0.036117048457696976]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>mnth_1</td>\n",
       "      <td>[-1381047771675.7356]</td>\n",
       "      <td>[-0.04673669085245069]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>mnth_11</td>\n",
       "      <td>[-1381047771675.741]</td>\n",
       "      <td>[-0.06329841124047164]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>mnth_12</td>\n",
       "      <td>[-1381047771675.7551]</td>\n",
       "      <td>[-0.06880745693602525]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>weathersit_1</td>\n",
       "      <td>[-1389533972631.3665]</td>\n",
       "      <td>[0.10538379254016594]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>weathersit_2</td>\n",
       "      <td>[-1389533972631.4177]</td>\n",
       "      <td>[0.0445354183790605]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>weathersit_3</td>\n",
       "      <td>[-1389533972631.6228]</td>\n",
       "      <td>[-0.14991921091922708]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[-7953866503007.055]</td>\n",
       "      <td>[0.024347940236536636]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-7953866503007.114]</td>\n",
       "      <td>[-0.028307002255112138]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>weekday_6</td>\n",
       "      <td>[-8199887241405.055]</td>\n",
       "      <td>[0.02609821881573071]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>weekday_0</td>\n",
       "      <td>[-8199887241405.101]</td>\n",
       "      <td>[-0.02213915679715603]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columns                 coef_lr                coef_ridge\n",
       "3       season_4     [8148280928973.255]     [0.09038628358992584]\n",
       "1       season_2     [8148280928973.168]     [0.01146000591769003]\n",
       "2       season_3     [8148280928973.135]   [-0.009498696186014288]\n",
       "0       season_1     [8148280928973.084]    [-0.09234759332160153]\n",
       "26          temp   [0.28970648628740114]      [0.2060652077451491]\n",
       "32            yr    [0.2316968278188186]     [0.23238474693113942]\n",
       "27         atemp   [0.12656335218459983]     [0.17792966011922565]\n",
       "29     windspeed  [-0.14211859647222003]    [-0.12452623640158374]\n",
       "28           hum  [-0.15917471278162595]    [-0.13008033628741705]\n",
       "24     weekday_5   [-246020738397.98853]    [0.009517613227277733]\n",
       "23     weekday_4    [-246020738397.9921]    [0.006972532701878531]\n",
       "22     weekday_3   [-246020738397.99387]   [0.0070049359952231716]\n",
       "21     weekday_2   [-246020738398.00458]  [-0.0038277183185988772]\n",
       "20     weekday_1    [-246020738398.0233]    [-0.02362642562435535]\n",
       "12        mnth_9   [-1381047771675.5918]     [0.08854943170182605]\n",
       "9         mnth_6   [-1381047771675.6436]    [0.040284304674968296]\n",
       "8         mnth_5   [-1381047771675.6443]    [0.038375549766223704]\n",
       "11        mnth_8    [-1381047771675.653]     [0.02955176157429122]\n",
       "13       mnth_10   [-1381047771675.6594]    [0.024689587768833565]\n",
       "6         mnth_3    [-1381047771675.672]      [0.0190571652561774]\n",
       "7         mnth_4    [-1381047771675.681]   [0.0013647004073436136]\n",
       "10        mnth_7   [-1381047771675.7122]   [-0.026912893663019744]\n",
       "5         mnth_2   [-1381047771675.7324]   [-0.036117048457696976]\n",
       "4         mnth_1   [-1381047771675.7356]    [-0.04673669085245069]\n",
       "14       mnth_11    [-1381047771675.741]    [-0.06329841124047164]\n",
       "15       mnth_12   [-1381047771675.7551]    [-0.06880745693602525]\n",
       "16  weathersit_1   [-1389533972631.3665]     [0.10538379254016594]\n",
       "17  weathersit_2   [-1389533972631.4177]      [0.0445354183790605]\n",
       "18  weathersit_3   [-1389533972631.6228]    [-0.14991921091922708]\n",
       "31    workingday    [-7953866503007.055]    [0.024347940236536636]\n",
       "30       holiday    [-7953866503007.114]   [-0.028307002255112138]\n",
       "25     weekday_6    [-8199887241405.055]     [0.02609821881573071]\n",
       "19     weekday_0    [-8199887241405.101]    [-0.02213915679715603]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The RMSE of LassoCV on test is 0.09224252293592122\n",
      "The RMSE of LassoCV on train is 0.08632465265926466\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lusha/.local/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:1108: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n",
      "/home/lusha/.local/lib/python3.6/site-packages/sklearn/model_selection/_split.py:1943: FutureWarning: You should specify a value for 'cv' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22.\n",
      "  warnings.warn(CV_WARNING, FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "#alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用RMSE评价模型在测试集和训练集上的性能\n",
    "print ('The RMSE of LassoCV on test is', np.sqrt(mean_squared_error(y_test, y_test_pred_lasso)))\n",
    "print ('The RMSE of LassoCV on train is', np.sqrt(mean_squared_error(y_train, y_train_pred_lasso)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3Xl8XXWd//HXJ2ubdE/Slm6kK9BS1lD2RWuxqENxBCnyUxQedhhlZhQdrYMios5P1JGfMzLOIEUWRVAEKbZQ0IKylNJ0o3SjabollGZtydJm/fz+uCflEpPmtunJXfJ+Ph73kbN8z7mfr7feN+d8zz3H3B0REZFjlRbvAkREJLkpSEREpFcUJCIi0isKEhER6RUFiYiI9IqCREREekVBIiIivaIgERGRXlGQiIhIr2SEuX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kdMvca/9WPoSzH+EyJVb2xOxL8DHifxHYxOwD1iWrJ9JLC9d/isiIr2iU1siItIrChIREekVBYmIiPSKgkRERHpFQSIiIr2iIBE5AjOr7+X2jwe/8D9SmxePdIfYWNt0al9gZs/G2l6kNxQkIiExsxlAuruX9vV7u3slsNfMLuzr95b+R0EiEgOL+JGZvRk8P+LaYHmamf138AyN581sqZldHWx2PfBU1D5+HtzMcqOZfaeb96k3s7uDNn82s4Ko1deY2etm9paZXRy0LzSzl8xsTfC6IKr9H4IaREKlIBGJzd8DZwCnAx8CfmRmJwTLC4HpwKeB86O2uZDIM0w63ObuRcBpwKVmdloX75MLFLv7DOAvvP/+XxnuPgv4UtTyCmCOu58FXAv8Z1T7YuDio++qyNHRTRtFYnMR8Bt3bwP2mdlfgHOC5b9z93bgHTN7IWqbE4DKqPlPBrcKzwjWTSdyi5Zo7cBjwfSvgCei1nVMryYSXgCZwM/M7AygDZgW1b6CyC05REKlIBEJz0FgAICZTQS+Cpzj7rVm9kDHuh5E38OoKfjbxnv/3/0ykXs5nU7kDMOhqPYDghpEQqVTWyKxeQm41szSg3GLS4DXgVeATwRjJaN4/23nNwNTgukhQANwIGh3RTfvkwZ0jLF8Cni5h7qGAnuDI6JPA+lR66aRrHeTlaSiIxKR2DxJZPxjPZGjhK+5+ztm9ntgNpFb5e8B1gAHgm2WEAmWP7n7ejNbS+R29XuIBFBXGoBZZvZNIqemru2hrv8Gfm9mnwGeDbbv8IGgBpFQ6e6/Ir1kZoPcvd7M8ogcpVwYhMxA4IVgvi3GfdW7+6DjVNdfgXkeed68SGh0RCLSe380s2FAFvBdDx5a5u4HzezbRJ4nvrsvCwpOv/1EISJ9QUckIiLSKxpsFxGRXlGQiIhIryhIRESkVxQkIiLSKwoSERHpFQWJiIj0yv8HJPyea+f6zvYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.00043984208333395553\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>coef_lasso</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>season_4</td>\n",
       "      <td>[8148280928973.255]</td>\n",
       "      <td>[0.09038628358992584]</td>\n",
       "      <td>0.066706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>season_2</td>\n",
       "      <td>[8148280928973.168]</td>\n",
       "      <td>[0.01146000591769003]</td>\n",
       "      <td>0.000400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>season_3</td>\n",
       "      <td>[8148280928973.135]</td>\n",
       "      <td>[-0.009498696186014288]</td>\n",
       "      <td>-0.008684</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>season_1</td>\n",
       "      <td>[8148280928973.084]</td>\n",
       "      <td>[-0.09234759332160153]</td>\n",
       "      <td>-0.117713</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.28970648628740114]</td>\n",
       "      <td>[0.2060652077451491]</td>\n",
       "      <td>0.310365</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>yr</td>\n",
       "      <td>[0.2316968278188186]</td>\n",
       "      <td>[0.23238474693113942]</td>\n",
       "      <td>0.232175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.12656335218459983]</td>\n",
       "      <td>[0.17792966011922565]</td>\n",
       "      <td>0.098628</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.14211859647222003]</td>\n",
       "      <td>[-0.12452623640158374]</td>\n",
       "      <td>-0.116440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.15917471278162595]</td>\n",
       "      <td>[-0.13008033628741705]</td>\n",
       "      <td>-0.115537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>weekday_5</td>\n",
       "      <td>[-246020738397.98853]</td>\n",
       "      <td>[0.009517613227277733]</td>\n",
       "      <td>0.001806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>weekday_4</td>\n",
       "      <td>[-246020738397.9921]</td>\n",
       "      <td>[0.006972532701878531]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>weekday_3</td>\n",
       "      <td>[-246020738397.99387]</td>\n",
       "      <td>[0.0070049359952231716]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>weekday_2</td>\n",
       "      <td>[-246020738398.00458]</td>\n",
       "      <td>[-0.0038277183185988772]</td>\n",
       "      <td>-0.005587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>weekday_1</td>\n",
       "      <td>[-246020738398.0233]</td>\n",
       "      <td>[-0.02362642562435535]</td>\n",
       "      <td>-0.026095</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>mnth_9</td>\n",
       "      <td>[-1381047771675.5918]</td>\n",
       "      <td>[0.08854943170182605]</td>\n",
       "      <td>0.066555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>mnth_6</td>\n",
       "      <td>[-1381047771675.6436]</td>\n",
       "      <td>[0.040284304674968296]</td>\n",
       "      <td>0.018832</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>mnth_5</td>\n",
       "      <td>[-1381047771675.6443]</td>\n",
       "      <td>[0.038375549766223704]</td>\n",
       "      <td>0.023929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>mnth_8</td>\n",
       "      <td>[-1381047771675.653]</td>\n",
       "      <td>[0.02955176157429122]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>mnth_10</td>\n",
       "      <td>[-1381047771675.6594]</td>\n",
       "      <td>[0.024689587768833565]</td>\n",
       "      <td>0.025575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>mnth_3</td>\n",
       "      <td>[-1381047771675.672]</td>\n",
       "      <td>[0.0190571652561774]</td>\n",
       "      <td>0.022012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>mnth_4</td>\n",
       "      <td>[-1381047771675.681]</td>\n",
       "      <td>[0.0013647004073436136]</td>\n",
       "      <td>-0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>mnth_7</td>\n",
       "      <td>[-1381047771675.7122]</td>\n",
       "      <td>[-0.026912893663019744]</td>\n",
       "      <td>-0.049361</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>mnth_2</td>\n",
       "      <td>[-1381047771675.7324]</td>\n",
       "      <td>[-0.036117048457696976]</td>\n",
       "      <td>-0.015498</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>mnth_1</td>\n",
       "      <td>[-1381047771675.7356]</td>\n",
       "      <td>[-0.04673669085245069]</td>\n",
       "      <td>-0.025210</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>mnth_11</td>\n",
       "      <td>[-1381047771675.741]</td>\n",
       "      <td>[-0.06329841124047164]</td>\n",
       "      <td>-0.047862</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>mnth_12</td>\n",
       "      <td>[-1381047771675.7551]</td>\n",
       "      <td>[-0.06880745693602525]</td>\n",
       "      <td>-0.051377</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>weathersit_1</td>\n",
       "      <td>[-1389533972631.3665]</td>\n",
       "      <td>[0.10538379254016594]</td>\n",
       "      <td>0.061779</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>weathersit_2</td>\n",
       "      <td>[-1389533972631.4177]</td>\n",
       "      <td>[0.0445354183790605]</td>\n",
       "      <td>-0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>weathersit_3</td>\n",
       "      <td>[-1389533972631.6228]</td>\n",
       "      <td>[-0.14991921091922708]</td>\n",
       "      <td>-0.190628</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[-7953866503007.055]</td>\n",
       "      <td>[0.024347940236536636]</td>\n",
       "      <td>0.006052</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-7953866503007.114]</td>\n",
       "      <td>[-0.028307002255112138]</td>\n",
       "      <td>-0.034714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>weekday_6</td>\n",
       "      <td>[-8199887241405.055]</td>\n",
       "      <td>[0.02609821881573071]</td>\n",
       "      <td>0.000340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>weekday_0</td>\n",
       "      <td>[-8199887241405.101]</td>\n",
       "      <td>[-0.02213915679715603]</td>\n",
       "      <td>-0.040901</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columns                 coef_lr                coef_ridge  coef_lasso\n",
       "3       season_4     [8148280928973.255]     [0.09038628358992584]    0.066706\n",
       "1       season_2     [8148280928973.168]     [0.01146000591769003]    0.000400\n",
       "2       season_3     [8148280928973.135]   [-0.009498696186014288]   -0.008684\n",
       "0       season_1     [8148280928973.084]    [-0.09234759332160153]   -0.117713\n",
       "26          temp   [0.28970648628740114]      [0.2060652077451491]    0.310365\n",
       "32            yr    [0.2316968278188186]     [0.23238474693113942]    0.232175\n",
       "27         atemp   [0.12656335218459983]     [0.17792966011922565]    0.098628\n",
       "29     windspeed  [-0.14211859647222003]    [-0.12452623640158374]   -0.116440\n",
       "28           hum  [-0.15917471278162595]    [-0.13008033628741705]   -0.115537\n",
       "24     weekday_5   [-246020738397.98853]    [0.009517613227277733]    0.001806\n",
       "23     weekday_4    [-246020738397.9921]    [0.006972532701878531]    0.000000\n",
       "22     weekday_3   [-246020738397.99387]   [0.0070049359952231716]    0.000000\n",
       "21     weekday_2   [-246020738398.00458]  [-0.0038277183185988772]   -0.005587\n",
       "20     weekday_1    [-246020738398.0233]    [-0.02362642562435535]   -0.026095\n",
       "12        mnth_9   [-1381047771675.5918]     [0.08854943170182605]    0.066555\n",
       "9         mnth_6   [-1381047771675.6436]    [0.040284304674968296]    0.018832\n",
       "8         mnth_5   [-1381047771675.6443]    [0.038375549766223704]    0.023929\n",
       "11        mnth_8    [-1381047771675.653]     [0.02955176157429122]    0.000000\n",
       "13       mnth_10   [-1381047771675.6594]    [0.024689587768833565]    0.025575\n",
       "6         mnth_3    [-1381047771675.672]      [0.0190571652561774]    0.022012\n",
       "7         mnth_4    [-1381047771675.681]   [0.0013647004073436136]   -0.000000\n",
       "10        mnth_7   [-1381047771675.7122]   [-0.026912893663019744]   -0.049361\n",
       "5         mnth_2   [-1381047771675.7324]   [-0.036117048457696976]   -0.015498\n",
       "4         mnth_1   [-1381047771675.7356]    [-0.04673669085245069]   -0.025210\n",
       "14       mnth_11    [-1381047771675.741]    [-0.06329841124047164]   -0.047862\n",
       "15       mnth_12   [-1381047771675.7551]    [-0.06880745693602525]   -0.051377\n",
       "16  weathersit_1   [-1389533972631.3665]     [0.10538379254016594]    0.061779\n",
       "17  weathersit_2   [-1389533972631.4177]      [0.0445354183790605]   -0.000000\n",
       "18  weathersit_3   [-1389533972631.6228]    [-0.14991921091922708]   -0.190628\n",
       "31    workingday    [-7953866503007.055]    [0.024347940236536636]    0.006052\n",
       "30       holiday    [-7953866503007.114]   [-0.028307002255112138]   -0.034714\n",
       "25     weekday_6    [-8199887241405.055]     [0.02609821881573071]    0.000340\n",
       "19     weekday_0    [-8199887241405.101]    [-0.02213915679715603]   -0.040901"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The RMSE of LinearRegression on test is 0.09472056824863244\n",
      "The RMSE of RidgeCV on test is 0.09335218835687427\n",
      "The RMSE of LassoCV on test is 0.09224252293592122\n"
     ]
    }
   ],
   "source": [
    "#测试集\n",
    "print ('The RMSE of LinearRegression on test is', np.sqrt(mean_squared_error(y_test, y_test_pred_lr)))\n",
    "print ('The RMSE of RidgeCV on test is', np.sqrt(mean_squared_error(y_test, y_test_pred_ridge)))\n",
    "print ('The RMSE of LassoCV on test is', np.sqrt(mean_squared_error(y_test, y_test_pred_lasso)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "作业：5.\t比较用上述三种模型得到的各特征的系数，以及各模型在测试集上的性能。并简单说明原因。\n",
    "答：1）线性回归：无正则回归系数有些非常大，有些非常小，变化幅度比较大。\n",
    "2）岭正则的系数基本都在0附近，这是因为我们加入了L2正则，假设系数在0均值附近浮动。\n",
    "3）Laaso回归的系数基本在0附近，也是因为加入L1正则，假设系数在0均值附近浮动。同时Lasso回归的个别系数会等于0，这也是L1正则有时候会得到稀疏解。\n",
    "4）均方误差小的性能好。LASSO的性能优于岭回归优于一般线性回归。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7rc1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
